#ifndef CLOCK_ALARMITEM_HPP
#define CLOCK_ALARMITEM_HPP

#include <cpp3ds/Graphics/Drawable.hpp>
#include <cpp3ds/Graphics/Text.hpp>
#include <cpp3ds/Window/Event.hpp>
#include <cpp3ds/System/Clock.hpp>
#include <cpp3ds/Audio/Sound.hpp>
#include <cpp3ds/Audio/Music.hpp>
#include "TweenObjects.hpp"
#include "Chronometer.hpp"
#include "States/State.hpp"
#include "GUI/ScrollBar.hpp"
#include <TweenEngine/Tween.h>
#include <TweenEngine/TweenManager.h>
#ifndef EMULATION
#include <3ds.h>
#endif

namespace Clock {

class AlarmItem : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
public:
	void update(float delta);
	void processEvent(const cpp3ds::Event& event);

	AlarmItem(int defaultHour = 0, int defaultMinute = 0, bool isEnabled = false, int index = 0);
	~AlarmItem();

	void setPosition(float posX, float posY);

	void setAlarmHour(int hour);
	void setAlarmMinute(int minute);
	int getAlarmHour();
	int getAlarmMinute();

	void resetAlarmCheck();

	void enableAlarm();
	void disableAlarm();
	bool isAlarmEnabled();

	void setIndex(int index);
	int getIndex();

	void updateTimeTexts();

protected:
	virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;

	int getNumberFromUser(int defaultNumber);
	void updateUnit(int *unit);

private:
	util3ds::TweenText m_textTimerHours;
	util3ds::TweenText m_textTimerMinutes;

	util3ds::TweenText m_textHourTwoPoints;

	util3ds::TweenRectangleShape m_separator;
	util3ds::TweenRectangleShape m_alarmButton;
	util3ds::TweenText m_textResetAlarm;

	int m_timeHour;
	int m_timeMinute;

	bool m_checkAlarm;
	bool m_isAlarmEnabled;

	cpp3ds::Music m_musicLoop;
	cpp3ds::Sound m_soundTimerOver;
	bool m_hasCustomMusic;

	int m_alarmIndex;

	TweenEngine::TweenManager m_tweenManager;

};

} // namespace Clock

#endif // CLOCK_ALARMITEM_HPP
